package ua_gov_energy_vkek_icelineacct.service;

import javax.ejb.EJB;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.QueryParam;
import ua_gov_energy_vkek_icelineacct.model.User;
import java.util.List;

/**
 * @author moroz
 */
@Path("/user")
public class UsersRS {

    @EJB
    UsersFacade facade;

    @GET
    @Path("{id:\\d+}")
    @Produces(MediaType.APPLICATION_JSON)
    public User getUserByID(@PathParam("id") int id) {
        return facade.get(id);
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<User> getUserList(
            @QueryParam("enabled") String enabled,
            @QueryParam("userGroup") String userGroup) {
        return facade.listByParams(enabled, userGroup, null);
    }
}
